package com.example.myservlet;

import cn.hutool.core.map.MapUtil;
import com.example.anno.RequestMapping;
import com.example.front.ThymeleafEngine;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@RequestMapping("/template")
public class TemplateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String html = ThymeleafEngine.process("user", MapUtil.of("name", "张三"));
        resp.setContentType("text/html; charset=UTF-8");
        resp.getWriter().write(html);

//        req.setCharacterEncoding("UTF-8");
//        String username = req.getParameter("username");
//        String password = req.getParameter("password");
//        resp.setContentType("text/plain;charset=UTF-8");
//        resp.getWriter().printf("username=%s, password=%s%n", username, password);
    }
}